#!/usr/bin/env bash 

sp='/-\|'
sc=0
spin() {
    printf "\b${sp:sc++:1}"
    ((sc==${#sp})) && sc=0
    sleep 0.1
}
endspin() {
    printf '\r%s\n' "$*"
    sleep 0.1
}
idx=0
until test $idx -gt 20 ; do
   spin
   idx=$((idx+1))
done
endspin